function init(solver_mode, netname)
if nargin < 2
    netname = '';
end

%%
if isempty(solver_mode)
    return
end

solver_mode = lower(solver_mode);
if ~isempty(strfind(solver_mode, 'cpu')) || ~mycaffe.useGPU(netname)
    caffe.set_mode_cpu();
    return
end

[i, j] = regexp(solver_mode, '\s+\d+');
gpu_idx = str2double(solver_mode(i:j));
caffe.set_mode_gpu();
caffe.set_device(gpu_idx);

% mycaffe.reset_all();
